// 待审批管理     模块

//引入mongoose模块
const mongoose = require('mongoose');
const { Schema } = mongoose;

//创建leaveSchema数据库模型
const leaveSchema = new Schema({
    orderNo: String, //订单号
    allTime: [String], //休假时间
    leaveTime: String, //休假时长
    applyType: {//休假类型
        default: 1,
        type: Number,
    },
    applyState: {//审批状态
        default: 1,
        type: Number,
    },
    reasons: String, //休假原因
    createTime: {
        type: Date,
        default: Date.now
    },
    auditUsers: String, //审批人
    curAuditUserName: String, //当前审批人
    applyUser: {//提交人
        userId: String,
        userName: String,
        userEmail: String,
    },
    auditFlows: [{//审批流程
        userId: String,
        userName: String,
        userEmail: String,
    }],
    auditLogs: [{//审批日志
        userId: String,
        userName: String,
        remark: String,//备注
        action: String,//审批通过或拒绝
        createTime: {//日志时间
            type: Date,
            default: Date.now,
        }
    }]
});

//定义leave模型并导出
module.exports = mongoose.model('leave', leaveSchema)